<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('任务中心')" />
	<th:block th:include="include :: list-css" />
	<style type="text/css">
		/* 		.first-ul{position: absolute;white-space: pre;z-index: 998;border-color:#fff !important;top:0;left:0} */
		.first-ul{position: absolute;white-space: normal;z-index: 998;width: 40px;top:0;left:0}
		.first-ul li{font-weight:600;padding:0;line-height:30px;min-width:40px}
		.layui-tab{margin:0px}
		.layui-tab-content{padding:0px}
		.layui-tab-title .layui-badge{border-radius: 10px;left:0}
		.layui-tab-title-one{height:32px;}
		.layui-tab-title-one li{background:#e5e5e5;}
		/* 		周报审核 */
		.flow-default1{
			background:#f2f2f2;
			/*padding:15px;*/
			height: -webkit-fill-available;
			overflow:auto;
			column-count: 3;
			-moz-column-count:3; /* Firefox */
			-webkit-column-count:3; /* Safari 和 Chrome */
			column-gap: 15px;
			column-rule: dashed;
		}
		.flow-default{
			/*background:#f2f2f2;*/
			height: -webkit-fill-available;
			overflow:auto;
			position: relative;
		}
		.flow-default li{
			float: left;
			position: absolute;
			z-index: 1;
		}
		.layui-table-tool{
			min-height:33px
		}
		.flow-default li.layui-btn{text-align:center}
		.layui-card{border-radius: 10px}
		.layui-card-header{line-height: 42px}
		.layuiadmin-normal-font{font-size:14px !important}
		/* 计划总结详情 */
		.week-detil a{color: #0093ff;position: relative;bottom: 17px;}
		.week-detil p a{bottom: 0;}
		.week-detil p{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: calc(100% - 40px);display: inline-block;}
		/* 		.layui-card .week-detil:hover p{overflow: visible;white-space: normal;} */
		/* 加载更多 */
		.layui-flow-more{width:100%}
		.layui-flow-more a cite{padding: 0;width: 98%;color: #fff;border-radius: 10px;margin-bottom: 10px;background-color: rgba(0, 150, 136,.75);box-shadow: 0 0 10px rgba(0,150,136,.25);}
		/* 报销费用金额 */
		.price{color: orangered;font-size: 30px}
		.price:before{content: '￥';font-size: 14px;}
		.mid-content{padding: 2px 3px 2px 10px;}
	</style>
</head>
<body>
<div class="main-content">
	<div class="content-right">
		<div class="search-top">
			<span>查询条件</span>
			<a href="javascript:;" layadmin-event="flexible" class="menuBtn">
				<i class="layui-icon layui-icon-spread-left" id="LAY_app_flexible" style="color: #fff;"></i>
			</a>
		</div>
		<div class="panel layout-expand layui-expand-east">
			<div class="panel-header">
				<div class="panel-tool" style="text-align: center; width: 26px;height: 30px;line-height: 30px;">
					<a href="javascript:;" layadmin-event="flexible" class="menuBtn">
						<i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible" style="color: #fff;"></i>
					</a>
				</div>
			</div>
			<div class="panel-body panel-title" style="text-align: center; width: 26px;">查<br>询<br>条<br>件</div>
		</div>
		<form class="layui-form">
			<div class="form1">
				<div class="layui-form layuiadmin-card-header-auto">
					<div class="layui-form-item">
						<label class="layui-form-label">流程标题：</label>
						<div class="layui-input-block">
							<input id="processTitle-kw" name="processTitle-kw" type="text" autocomplete="off" class="layui-input">
							<a class='dhicon dh-undo search-repeat' data-name="processTitle-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">流程名称：</label>
						<div class="layui-input-block">
							<input id="defName-kw" name="defName-kw" type="text" autocomplete="off" class="layui-input">
							<a class='dhicon dh-undo search-repeat' data-name="defName-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">所属公司：</label>
						<div class="layui-input-block">
							<input id="corpName" name="corpName" type="text" autocomplete="off" class="layui-input buttontext">
							<i class="layui-icon layui-icon-more getMore" onclick="getMore('corpName',null,'所属公司','tb_companyinfo',true);" gettype="corpName"></i>
							<a class='dhicon dh-undo search-repeat' data-name="corpName">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">发起人：</label>
						<div class="layui-input-block">
							<input id="organizerName" name="organizerName" type="text" autocomplete="off" class="layui-input buttontext">
							<i class="layui-icon layui-icon-more getMore" onclick="getMore('organizerName',null,'发起人','ts_userinfo',true);" gettype="organizerName"></i>
							<a class='dhicon dh-undo search-repeat' data-name="organizerName">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-0" style="display:none">
						<label class="layui-form-label">流程标识：</label>
						<div class="layui-input-block">
							<input id="defKey-kw" name="defKey-kw" type="text" autocomplete="off" class="layui-input">
							<a class='dhicon dh-undo search-repeat' data-name="defKey-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-1">
						<label class="layui-form-label">任务名称：</label>
						<div class="layui-input-block">
							<input id="taskName-kw" name="taskName-kw" type="text" autocomplete="off" class="layui-input">
							<a class='dhicon dh-undo search-repeat' data-name="taskName-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-2" style="display:none">
						<label class="layui-form-label">当前环节：</label>
						<div class="layui-input-block">
							<input id="curTaskName-kw" name="curTaskName-kw" type="text" autocomplete="off" class="layui-input">
							<a class='dhicon dh-undo search-repeat' data-name="curTaskName-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-3">
						<label class="layui-form-label">创建时间：</label>
						<div class="layui-input-block">
							<input style="display: none;" id="startTime" name="time-kw">
							<input style="display: none;" id="endTime" name="time-kw">
							<input id="time-kw" name="time-kw" type="text" autocomplete="off" class="layui-input"><i class="dhicon dh-calendar icon_date_business"></i>
							<a class='dhicon dh-undo search-repeat' data-name="time-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-4" style="display:none">
						<label class="layui-form-label">开始时间：</label>
						<div class="layui-input-block">
							<input style="display: none;"  id="startQuerySt" name="startTime-kw">
							<input style="display: none;"  id="startQueryEt" name="startTime-kw">
							<input id="startTime-kw" name="startTime-kw" type="text" autocomplete="off" class="layui-input"><i class="dhicon dh-calendar icon_date_business"></i>
							<a class='dhicon dh-undo search-repeat' data-name="startTime-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-4" style="display:none">
						<label class="layui-form-label">结束时间：</label>
						<div class="layui-input-block">
							<input style="display: none;"  id="endQuerySt" name="endTime-kw">
							<input style="display: none;" id="endQueryEt" name="endTime-kw">
							<input id="endTime-kw" name="endTime-kw" type="text" autocomplete="off" class="layui-input"><i class="dhicon dh-calendar icon_date_business"></i>
							<a class='dhicon dh-undo search-repeat' data-name="endTime-kw">&nbsp;</a>
						</div>
					</div>
					<div class="layui-form-item form-1 form-1-5" th:if="${buttonState['show-week']} eq 'enable'">
						<label class="layui-form-label">过滤审核周报：</label>
						<div class="layui-input-block">
							<input type='checkbox' name="filterWeekly" id="filterWeekly" lay-skin="primary">
							<a class='dhicon dh-undo search-repeat' data-name="filterWeekly">&nbsp;</a>
						</div>
					</div>
				</div>
			</div>
			<div class="form2" style="display:none">
				<th:block th:include="listinclude :: searchRightWithMT('TS_MODULETASK')" />
			</div>
			<div class="form3" style="display:none" th:if="${buttonState['show-week']} eq 'enable'">
				<th:block th:include="listinclude :: searchRightWithMT('TCRM_WEEKLYPLAN')" />
			</div>
			<div class="form4" style="display:none" th:if="${buttonState['show-week']} eq 'enable'">
				<th:block th:include="listinclude :: searchRightWithMT('TCRM_WEEKLYFINISH')" />
			</div>
			<div class="layui-form-item btn-item">
				<a class="layui-btn layuiadmin-btn-order dhicon dh-search" id="btn-search0"><span class="fa_span">查询</span></a>
				<button type="reset" class="layui-btn layui-btn-primary dhicon dh-refresh reset" id="dh-resets"><span class="fa_span">重置</span></button>
			</div>
		</form>
	</div>
	<div class="mid-content mid-content-box">
		<div class="layui-tab first-tab" lay-filter="dhtab">
			<ul class="layui-tab-title layui-tab-title-one" id="new-task" style="border-width: 0px;">
				<li class="layui-this">流程任务<p class="layui-badge badge1">0</p></li>
				<li>功能任务<p class="layui-badge badge2">0</p></li>
				<li th:if="${buttonState['show-week']} eq 'enable'">计划总结<p class="layui-badge badge3">0</p></li>
			</ul>
			<div class="layui-tab-content" style="margin-top: 7px;">
				<div class="layui-tab-item layui-show">
					<div class="layui-tab" lay-filter="dhtab2">
						<ul class="layui-tab-title">
							<li listUrl="/flowable/task/todoTaskList" class="layui-this">待办任务</li>
							<li listUrl="/flowable/task/doneTaskList">已办任务</li>
							<li listUrl="/flowable/process/runProcessList">运行中的流程</li>
							<li listUrl="/flowable/process/finishProcessList">结束的流程</li>
						</ul>
						<div class="layui-tab-content layui-tab-box" style="border: 0px solid ;padding: 0px 2px 0px 0px;background: #FFF;">
							<table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
						</div>
					</div>
				</div>
				<div class="layui-tab-item">
					<div class="layui-tab" lay-filter="dhtab3">
						<ul class="layui-tab-title">
							<li listUrl="/system/moduletask/listwcl" class="layui-this">未处理</li>
							<li listUrl="/system/moduletask/listycl">已处理</li>
							<li listUrl="/system/moduletask/listyfs">已发送</li>
						</ul>
						<div class="layui-tab-content layui-tab-box" style="border: 0px solid #0087fa;padding: 0px 2px 0px 0px;background: #FFF;">
							<table class="layui-hide" id="dhtable2" lay-filter="ftable2"></table>
						</div>
					</div>
				</div>
				<div class="layui-tab-item" th:if="${buttonState['show-week']} eq 'enable'">
					<div class="layui-tab" lay-filter="dhtab4">
						<ul class="layui-tab-title">
							<li class="layui-this">计划</li>
							<li>总结</li>
							<div class="f_r" style="height:33px">
								<div class="layui-btn-container" style="top: 50%;position: relative;margin-top: -15px;">
									<div class="layui-btn layui-btn-danger layui-table-tools" onclick="allRorT(1)">
										<i class="dhicon dh-reply"></i> 全部退回
									</div>
									<div class="layui-btn layui-table-tools" onclick="allRorT(2)">
										<i class="dhicon dh-check"></i> 全部通过
									</div>
								</div>
							</div>
						</ul>
						<div class="layui-progress layui-progress-big layui-hide" lay-showpercent="true" lay-filter="weekProgress" id="weekProgress">
							<div class="layui-progress-bar" lay-percent="0%" id="weekProgress_child"></div>
						</div>
						<div class="layui-tab-content layui-tab-box" style="border: 0px solid #0087fa;padding: 0px 2px 0px 0px;background: #FFF;">
							<ul class="flow-default" id="weekFlow"></ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: searchJS" />
<!-- 流程任务操作区 -->
<script type="text/html" id="barDh0">
	{{# if($("[lay-filter=dhtab2] .layui-this").index()==0){ }}
	<a class="layui-btn layui-btn-xs dhicon dh-edit" lay-event="deal"> 处理</a>
	{{# if(d.key.toLowerCase()=='folwzd' || d.name.indexOf('制单') != -1){ }}
	<a class="layui-btn layui-btn-xs dhicon dh-street-view layui-btn-warm layui-btn-disabled"> 委托</a>
	{{# }else{ }}
	<a class="layui-btn layui-btn-xs dhicon dh-street-view layui-btn-warm" lay-event="delegate"> 委托</a>
	{{# } }}
	{{# }else{ }}
	<a class="layui-btn layui-btn-xs dhicon dh-edit" lay-event="jump"> 表单数据</a>
	{{# } }}
	<a class="layui-btn layui-btn-xs dhicon dh-play-circle-o layui-btn-normal" lay-event="speed"> 流程跟踪</a>
</script>
<!-- 功能任务操作区 -->
<script type="text/html" id="barDh">
	{{# if(d.moduleTable=='Commonality_Deal_Repeat'){ }}
	<a class="layui-btn layui-btn-xs dhicon dh-search layui-btn-warm" onclick="newTab('{{d.pageURL}}','{{d.pageTitle}}');">&nbsp;详情</a>
	{{# }else{ }}
	<a class="layui-btn layui-btn-xs dhicon dh-eye" onclick="read('{{d.pageURL}}','{{d.pageTitle}}','{{d.cUser}}','{{d.cUserName}}',{{d.LAY_TABLE_INDEX}})">&nbsp;查看</a>
	{{# } }}
</script>
<!-- 特殊字段自定义模板 -->
<script type="text/html" id="templet_procDefVersion">
	v.{{d.procDefVersion}}
</script>
<script type="text/html" id="templet_suspendState">
	{{# return (d.suspendState==1)?"已激活":"<span style='color:red'>已挂起</span>"; }}
</script>
<script type="text/html" id="templet_owner">
	{{# return (d.ownerName == null)?"":d.ownerName; }}
</script>
<script type="text/html" id="templet_duration">
	{{# if (!d.duration)return ""; }}
	{{# let s = d.duration / 1000;if (s < 60)return s.toFixed(0) + " 秒"; }}
	{{# let m = s / 60;if (m < 60)return m.toFixed(0) + " 分钟"; }}
	{{# let h = m / 60;if (h < 24)return h.toFixed(0) + " 小时"; }}
	{{# let day = h / 24;if (day < 30)return day.toFixed(0) + " 天"; }}
	{{# let month = day / 30;if (month < 12)return month.toFixed(0) + " 个月"; }}
	{{# let year = month / 12;return year.toFixed(0) + " 年"; }}
</script>
<script type="text/html" id="templet_priority">
	{{# if(d.priority == 1){return "一般"; }}
	{{# }else if(d.priority == 2){return "<span style='color:blue'>重要</span>"; }}
	{{# }else if(d.priority == 3){return "<span style='color:red'>紧急</span>"; }}
	{{# }else{return "";} }}
</script>
<script type="text/html" id="templet_taskState">
	{{# if(d.taskState=='未处理'){return "<span style='color:blue'>未处理</span>"; }}
	{{# }else if(d.taskState.indexOf('超时')>-1){return "<span style='color:red'>"+d.taskState+"</span>"; }}
	{{# }else{return "<span style='color:green'>"+d.taskState+"</span>";} }}
</script>
<script th:inline="javascript">
	/*<![CDATA[*/
	var gridColumns=[[${gridColumns}]];
	var gridColumns2=[[${gridColumns2}]];
	var session=[[${session}]];
	var buttonState=[[${buttonState}]];
	var moduleTable=[[${moduleTable}]];
	var moduleTable2=[[${moduleTable2}]];
	gridColumns.gridBody[gridColumns.gridBody.length-1].toolbar='#barDh0';//修改流程任务操作区为barDh0
	gridColumns2.gridBody[gridColumns2.gridBody.length-1].toolbar='#barDh0';//修改流程任务操作区为barDh0
	/*]]>*/
</script>
<script type="text/javascript">
	var $,layer,form,element,table,laydate,flow,wherestr={},listData=[];
	var gap = 10,columns = 3;//流加载dom间隔，列数
	var urlParameters = '';//计划总结参选参数
	var prefix = ctx + "flowable/task";//待办任务、已办任务
	var prefix2 = ctx + "flowable/process";//运行中的流程、结束的流程
	var weekPage = 1,weekLimit = 9,liList = [];;//计划总结流加载页数计数以及每页个数
	layui.use(['table','form','layer','jquery','element','laydate','flow'], function () {
		$ = layui.$, layer = layui.layer, form = layui.form, table = layui.table, element = layui.element,laydate=layui.laydate,flow=layui.flow;
		layer.config({extend: 'myskin/style.css'});//加载扩展样式
		$('[lay-filter="dhtab4"] .layui-tab-content').height($(window).height()-43);//限制计划总结,统一tab页内容高度（瀑布流布局高度）
		// $('.first-tab').attr('style','border:1px solid '+logo_color);//选项卡修改样式
		$('.form2 .btn-item').remove();//删除searchRight自带的按钮
		$('.form3 .btn-item').remove();//删除searchRight自带的按钮
		$('.form4 .btn-item').remove();//删除searchRight自带的按钮
		$.each(gridColumns.gridBody,function(i,v){
			if(v.hide)v.hideFLag=true;
		})
		$.each(gridColumns2.gridBody,function(i,v){
			if(v.hide)v.hideFLag=true;
		})
		serachRender();//查询条件初始渲染集合
		refreshTask();//刷新通知数量
		laydate.render({elem: '#time-kw',type:'datetime',range: '~',done: function (value, date, endDate) {spiltTime(value,date,endDate,'startTime','endTime');}});
		laydate.render({elem: '#startTime-kw',type:'datetime',range: '~',done: function (value, date, endDate) {spiltTime(value,date,endDate,'startQuerySt','startQueryEt');}});
		laydate.render({elem: '#endTime-kw',type:'datetime',range: '~',done: function (value, date, endDate) {spiltTime(value,date,endDate,'endQuerySt','endQueryEt');}});
		$.each(gridColumns.gridBody,function(i,v){//初始共用列的隐藏
			if($.inArray(v.field,['resultStatusName','comment','duration','startTime','endTime'])>-1 || v.hideFLag)v.hide=true;
			else v.hide=false;
		})
		$.tablelist.init({//dhtable初始化、默认加载待办任务
			elem: '#dhtable',
			url:'/flowable/task/todoTaskList',
			even:true,
			height:'full-123',
			totalRow: false,
			cols:[gridColumns.gridBody
			],
			where: {field: 'createTime',order: 'desc'},
			toolbar: true,//仅开启工具栏，不显示左侧模板
			defaultToolbar: [{title:'列设置',layEvent: 'fieldSet1',icon: 'layui-icon-set'}]
		});
		table.on('toolbar(ftable)', function(obj){//头工具栏事件
			switch(obj.event){
				case 'fieldSet1'://待办任务、已办任务使用ACT_HI_TASKINST
					filedSet(gridColumns.moduleTable);
					break;
				case 'fieldSet2'://运行中的流程、结束的流程使用ACT_HI_PROCINST
					filedSet(gridColumns2.moduleTable);
					break;
			};
		});
		$(".layui-tab-box").css("border-color",JSON.parse(window.localStorage.getItem('layuiAdmin')).theme.color.header)
		$.get('/system/moduletask/grid',function(res){//获取表格列并初始化dhtable2
			$.tablelist.init({
				elem: '#dhtable2',
				url:'/system/moduletask/listwcl',
				even:res.readOnly,
				height:'full-123',
				totalRow: res.totalRow,
				cols:[res.gridBody
				],
				where: {field: 'createTime',order: 'desc'},
				toolbar: true,//仅开启工具栏，不显示左侧模板
				defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}]
			});
			table.on('toolbar(ftable2)', function(obj){//头工具栏事件
				switch(obj.event){
					case 'fieldSet':
						filedSet(res.moduleTable);
						break;
				};
			});
		});
		table.on('sort(ftable)', function(obj){//监听排序事件 (dhtable)
			$.tablelist.sort('dhtable',obj);
		});
		table.on('sort(ftable2)', function(obj){//监听排序事件 (dhtable2)
			$.tablelist.sort('dhtable2',obj);
		});
		element.on('tab()',function(data){//监听Tab页（通用默认动作）
			$("button[type='reset']").click();//清空所有输入框
		})
		element.on('tab(dhtab)', function(data){//监听Tab页（一级选项卡）
			if(data.index==0){
				table.reload('dhtable');//每次切换到流程任务则重载dhtable
				$('.form1').show();
				$('.form2').hide();
				$('.form3').hide();
				$('.form4').hide();
			}
			if(data.index==1){
				table.reload('dhtable2');//每次切换到功能任务则重载dhtable2
				$('.form1').hide();
				$('.form2').show();
				$('.form3').hide();
				$('.form4').hide();
				table.reload('dhtable2');
			}
			if(data.index==2){//第一次切换到计划总结则流加载周报计划
				$('.form1').hide();
				$('.form2').hide();
				$('.form3').show();
				$('.form4').hide();
				if($('.layui-flow-more').length == 0)flowPlan();//判断是否产生更多代码块
			}
		});
		element.on('tab(dhtab2)', function(data){//监听Tab页（流程任务）
			var fieldSet,gb;//列设置使用的动作、数据表格使用的列对象
			$('.form-1').hide();
			if(data.index==0){//待办任务
				$('.form-1-1').show();
				$('.form-1-3').show();
				$('.form-1-5').show();
				$.each(gridColumns.gridBody,function(i,v){
					if($.inArray(v.field,['resultStatusName','comment','duration','startTime','endTime'])>-1 || v.hideFLag)v.hide=true;
					else v.hide=false;
				})
				gb=gridColumns.gridBody;
				gridColumns.gridBody[gridColumns.gridBody.length-1].width=270;//修改流程任务操作区宽度
				fieldSet='fieldSet1';
			}
			if(data.index==1){//已办任务
				$('.form-1-1').show();
				$('.form-1-4').show();
				$.each(gridColumns.gridBody,function(i,v){
					if($.inArray(v.field,['createTime','actComment'])>-1 || v.hideFLag)v.hide=true;
					else v.hide=false;
				})
				gb=gridColumns.gridBody;
				gridColumns.gridBody[gridColumns.gridBody.length-1].width=240;//修改流程任务操作区宽度
				fieldSet='fieldSet1';
			}
			if(data.index==2){//运行中的流程
				$('.form-1-0').show();
				$('.form-1-2').show();
				$('.form-1-3').show();
				$.each(gridColumns2.gridBody,function(i,v){
					if($.inArray(v.field,['resultStatusName','duration','startTime','endTime'])>-1 || v.hideFLag)v.hide=true;
					else v.hide=false;
				})
				gb=gridColumns.gridBody;
				gridColumns.gridBody[gridColumns.gridBody.length-1].width=230;//修改流程任务操作区宽度
				fieldSet='fieldSet2';
			}
			if(data.index==3){//结束的流程
				$('.form-1-0').show();
				$('.form-1-4').show();
				$.each(gridColumns2.gridBody,function(i,v){
					if($.inArray(v.field,['curTaskName','suspendState','createTime'])>-1  || v.hideFLag)v.hide=true;
					else v.hide=false;
				})
				gb=gridColumns.gridBody;
				gridColumns.gridBody[gridColumns.gridBody.length-1].width=230;//修改流程任务操作区宽度
				fieldSet='fieldSet2';
			}
			$.tablelist.init({//dhtable初始化,替换数据源及表格列
				elem: '#dhtable',
				url:$(this).attr('listUrl'),
				even:true,
				height:'full-123',
				totalRow: false,
				cols:[gb
				],
				where: {field: 'createTime',order: 'desc'},
				toolbar: true,//仅开启工具栏，不显示左侧模板,
				defaultToolbar: [{title:'列设置',layEvent: fieldSet,icon: 'layui-icon-set'}]
			});
		});
		element.on('tab(dhtab3)', function(data){//监听Tab页（功能任务）
			table.reload('dhtable2',{url:$(this).attr('listUrl')});
		});
		element.on('tab(dhtab4)', function(data){//监听Tab页（计划总结）
			weekPage = 1;//重置页数
			listData = [];//重置当前tab页数据
			$('.flow-default li').remove();
			$('.layui-flow-more').remove();
			if(data.index==0){//计划
				$('.form3').show();
				$('.form4').hide();
				flowPlan();//流加载周报计划
			}
			if(data.index==1){//总结
				$('.form3').hide();
				$('.form4').show();
				$('.form4 #createTime').parents('.layui-form-item').hide();
				$('.form4 #updateTime').parents('.layui-form-item').hide();
//  			$('.form3 #createTime').parents('.layui-form-item').show();
//  			$('.form3 #updateTime').parents('.layui-form-item').show();
				flowFinish();//流加载周报总结
			}
		});
		table.on('tool(ftable)', function (obj) {//监听dhtable工具条
			var data = obj.data;
			switch(obj.event){
				case 'deal'://处理
				case 'jump'://表单数据
					console.log("表单数据",data);
					var route = "";
					if(data.procDefKey === 'TCG_Payment'){//无新增导航 特殊任务处理
						route = "/purchase/payment/edit";
					} else {
						route = data.routeUrl
					}
					var routeUrl = route + "?taskId=" + data.id + "&nid="+data.tableDataId;
					parent.layui.index.openTabsPage(routeUrl, data.processTitle);
					break;
				case 'reject'://驳回
					var judgeUrl =  prefix + "/judgeRejectCond?activityId="+data.key;
					$.get(judgeUrl, function(res){
						if(res.code==0){
							var url = prefix + "/taskReject?taskId="+data.id;
							$.modal.open("流程驳回", url, 700, 620);
						}else{
							$.operate.ajaxSuccess(res);
						}
					})
					break;
				case 'delegate'://委托
					var url = prefix+"/taskDelegate?taskId="+data.id;
					$.modal.open("委托他人代办", url, 700, 620);
					break;
				case 'speed'://流程跟踪
					var width = 800;
					var height = ($(window).height() - 150);
					var url = prefix2+"/processSpeed/" + data.procInstId;
					layer.open({
						type: 2,
						area: [width + 'px', height + 'px'],
						offset: '10%',//距离顶部10%
						fix: false,
						//不固定
						maxmin: true,
						shade: 0.6,
						title: "流程跟踪",
						content:  url,
						btn: ['关闭'],
						//点击弹层外区域关闭
						shadeClose: true,
						cancel: function(index) {
							return true;
						}
					});
					break;
			}
		});
	});
	$('#btn-search0').on('click', function () {//通过判断流程任务表单是否显示
		refreshTask();//刷新通知数量
		if($('.form1').css('display')=='block'){//流程任务
			console.log('流程任务');
			table.reload('dhtable', {page: {curr: 1},
				where:{
					corpName:$('#corpName').val(),
					processTitle:$("#processTitle-kw").val(),
					name:$("#taskName-kw").val(),
					organizerName:$("#organizerName").val(),
					defKey:$("#defKey-kw").val(),
					defName:$("#defName-kw").val(),
					curTaskName:$("#curTaskName-kw").val(),
					startTime:$("#startTime").val(),
					endTime:$("#endTime").val(),
					startQuerySt:$("#startQuerySt").val(),
					startQueryEt:$("#startQueryEt").val(),
					endQuerySt:$("#endQuerySt").val(),
					endQueryEt:$("#endQueryEt").val(),
					filterWeekly:$('#filterWeekly').prop("checked")?1:0
				}
			});
		}else if($('.form2').css('display')=='block'){//功能任务
			console.log('功能任务',getWherestr('.form2 '));
			table.reload('dhtable2', {page: {curr: 1},where:getWherestr('.form2 ')});
		}else if($('.form3').css('display')=='block'){//周报计划
			weekPage = 1;//重置页数
			listData = [];//重置当前tab页数据
			urlParameters='?';
			$.each(getWherestr('.form3 '),function(i,v){
				if(v)urlParameters+=i+'='+v+'&';
			})
			urlParameters = urlParameters.substring(0,urlParameters.length-1);
			console.log('周报计划',urlParameters);
			$('.flow-default li').remove();
			$('.layui-flow-more').remove();
			flowPlan('/flowable/weekly/weeklyplan'+urlParameters);
// 		if($("[lay-filter=dhtab4] .layui-tab-title .layui-this").index()==0)flowPlan('/flowable/weekly/weeklyplan'+urlParameters);
// 		if($("[lay-filter=dhtab4] .layui-tab-title .layui-this").index()==1)flowFinish('/flowable/weekly/weeklyfinish'+urlParameters);
		}else if($('.form4').css('display')=='block'){//周报总结
			weekPage = 1;//重置页数
			listData = [];//重置当前tab页数据
			urlParameters='?';
			$.each(getWherestr('.form4 '),function(i,v){
				if(v)urlParameters+=i+'='+v+'&';
			})
			urlParameters = urlParameters.substring(0,urlParameters.length-1);
			console.log('周报总结',urlParameters);
			$('.flow-default li').remove();
			$('.layui-flow-more').remove();
			flowFinish('/flowable/weekly/weeklyfinish'+urlParameters);
		}
	});
	function flowPlan(url='/flowable/weekly/weeklyplan'){//流加载周报计划
		flow.load({
			elem: '#weekFlow' //指定列表容器
// 		,end: liList.length?' ':''//用于显示末页内容，可传入任意HTML字符
			,isAuto: false//是否自动加载
			,scrollElem: '#weekFlow'//滚动条所在元素选择器
			,done: function(page, next){//到达临界点，触发下一页
				liList=[];
				$.get(url+(url.split('?')[1]?'&':'?')+'page='+weekPage+'&limit='+weekLimit, function(res){
					if(res.code == 0){
// 			        for(var i=0; i<res.data.length-1; i++){//冒泡排序，根据首个计划日期升序
// 						for(var j=0; j<res.data.length-i-1; j++){
// 							if(res.data[j].planList[0].dPlanDate>res.data[j+1].planList[0].dPlanDate)res.data[j]=[res.data[j+1],res.data[j+1]=res.data[j]][0];
// 					    }
// 					}
						$.each(res.data,function(i,v){
							if(v.planList.length>0){
								listData.push(v);
								var liHtml='<li><div class="layui-card">';
								liHtml+='<div class="layui-card-header">';
								liHtml+='<i class="dhicon dh-user-circle"></i>  '+v.organizerName;
								liHtml+='<a class="layui-badge layui-bg-green layuiadmin-badge" onclick="newTab(\'/crm/weeklyplan/edit?nid='+v.planList[0].nid+'\',\'周报计划('+v.planList[0].bid+')\')" lay-tips="<span style=\'color:lightblue\'>温馨提示</span>：点击跳转到<span style=\'color:red\'>单据</span>详情">查看</a>';
								liHtml+='</div>';
								liHtml+='<div class="layui-card-body layuiadmin-card-list">';
								$.each(v.planList,function(j,k){
									liHtml+='<p class="layuiadmin-normal-font">计划日期：'+k.dPlanDate+'</p>';
									liHtml+='<p class="layuiadmin-normal-font">客户：'+k.gCName+'</p>';
									liHtml+='<p class="layuiadmin-normal-font">联系人：'+k.vMan+'</p>';
									liHtml+='<p class="layuiadmin-normal-font">地址：'+k.vPlanAddress+'</p>';
									liHtml+=(j==0?'<div class="week-detil">':'')+'<p class="layuiadmin-normal-font">计划：'+k.vPlanWork;
									liHtml+='<a class="dhicon dh-angle-double-up" onClick="hideDetail(this)" style="display: none;">收起</a></p>';
									liHtml+='<a class="dhicon dh-angle-double-down" onClick="showDetail(this)">展开</a>';
									if(j<v.planList.length-1)liHtml+='<hr/>';
									else liHtml+='</div>';
								})
								liHtml+='<div style="text-align:center">';
								liHtml+='<div class="layui-btn layui-btn-danger layui-table-tools" onclick="transferReturn(1,'+(listData.length-1)+')"><i class="dhicon dh-reply"></i> 退回</div>';
								liHtml+='<div class="layui-btn layui-table-tools" onclick="transferReturn(3,'+(listData.length-1)+')"><i class="dhicon dh-check"></i> 通过</div>';
								liHtml+='</div></div></div></li>';
								liList.push(liHtml);
							}
						})
					}else layer.msg(res.msg);
					next(liList.join(''), res.count?(weekPage*weekLimit)<res.count:false);
					weekPage++;//流加载页数
					waterFall($('#weekFlow').find('li'));
				});
			}
		});
	}
	function flowFinish(url='/flowable/weekly/weeklyfinish'){//流加载周报总结routeUrl
		flow.load({
			elem: '#weekFlow' //指定列表容器
// 		,end: liList.length?' ':''//用于显示末页内容，可传入任意HTML字符
			,isAuto: false//是否自动加载
			,scrollElem: '#weekFlow'//滚动条所在元素选择器
			,done: function(page, next){ //到达临界点，触发下一页
				liList = [];
				$.get(url+(url.split('?')[1]?'&':'?')+'page='+weekPage+'&limit='+weekLimit, function(res){
					if(res.code == 0){
// 			        for(var i=0; i<res.data.length-1; i++){//冒泡排序，根据总结日期升序
// 						for(var j=0; j<res.data.length-i-1; j++){
// 							if(res.data[j].finishList[0].dFinishDate>res.data[j+1].finishList[0].dFinishDate)res.data[j]=[res.data[j+1],res.data[j+1]=res.data[j]][0];
// 					    }
// 					}
						$.each(res.data,function(i,v){
							if(v.finishList.length>0){
								listData.push(v);
								var totalSum = 0;//合计报销费用
								var detailHtml = '';
								$.each(v.finishList,function(j,k){
									detailHtml+='<p class="layuiadmin-normal-font">客户：'+k.gCName+'</p>';
									detailHtml+='<p class="layuiadmin-normal-font">联系人：'+k.vMan+'</p>';
									detailHtml+='<p class="layuiadmin-normal-font">地点：'+(k.vProvince?k.vProvince:'')+(k.vCity?k.vCity:'')+'</p>';
									detailHtml+=(j==0?'<div class="week-detil">':'')+'<p class="layuiadmin-normal-font">工作总结：'+k.vFinishWork;
// 								k.vFinishWork = k.vFinishWork.replaceAll('\n','<br/>');
									detailHtml+='<a class="dhicon dh-angle-double-up" onClick="hideDetail(this)" style="display: none;">收起</a></p>';
									detailHtml+='<a class="dhicon dh-angle-double-down" onClick="showDetail(this)">展开</a>';
//									detailHtml+='<p class="layuiadmin-normal-font">后续进展：'+k.vNextWork+'</p>';
									totalSum+=k.fTotalJe;//合计报销费用
									if(j<v.finishList.length-1)detailHtml+='<hr/>';
									else detailHtml+='</div>';
								})
								var liHtml='<li><div class="layui-card">';
								liHtml+='<div class="layui-card-header">';
								liHtml+=' <i class="dhicon dh-user-circle"></i> '+v.organizerName;
								liHtml+='<a class="layui-badge layui-bg-green layuiadmin-badge" onclick="newTab(\'/crm/weeklyfinish/edit?nid='+v.finishList[0].nid+'\',\'周报总结('+v.finishList[0].bid+')\')" lay-tips="<span style=\'color:lightblue\'>温馨提示</span>：点击跳转到<span style=\'color:red\'>单据</span>详情">查看</a>';
								liHtml+='</div>';
								liHtml+='<div class="layui-card-body layuiadmin-card-list">';
								liHtml+='<p class="layuiadmin-normal-font" style="text-align:center"><a class="price" onclick="openSumDetail('+((weekPage-1)*weekLimit+i)+')" lay-tips="<span style=\'color:lightblue\'>温馨提示</span>：点击查看<span style=\'color:red\'>报销费用</span>详情">'+totalSum.toFixed(2)+'</a>/报销费用</p>';
								liHtml+='<p class="layuiadmin-normal-font">总结日期：'+v.finishList[0].dFinishDate+'</p>';
								liHtml+='<hr/>';
								liHtml+=detailHtml;
								liHtml+='<div style="text-align:center">';
								liHtml+='<div class="layui-btn layui-btn-danger layui-table-tools" onclick="transferReturn(2,'+(listData.length-1)+')"><i class="dhicon dh-reply"></i> 退回</div>';
								liHtml+='<div class="layui-btn layui-table-tools" onclick="transferReturn(4,'+(listData.length-1)+')"><i class="dhicon dh-check"></i> 通过</div>';
								liHtml+='</div></div></div></li>';
								liList.push(liHtml);
							}
						})
					}else layer.msg(res.msg);
					next(liList.join(''), res.count?(weekPage*weekLimit)<res.count:false);
					weekPage++;//流加载页数
					waterFall($('#weekFlow').find('li'));
				});
			}
		});
	}
	function showDetail(e){//展开详情
		$(e).hide();
// 	$(e).prev().html($(e).prev().text().replaceAll('\n','<br>'));
		$(e).prev().css('overflow','visible');
		$(e).prev().css('white-space','normal');
		$(e).prev().css('width','100%');
		$(e).prev().find('a').show();
	}
	function hideDetail(e){//收起详情
		$(e).hide();
// 	$(e).html($(e).text().replaceAll('<br/>','\n'));
		$(e).parent().css('overflow','hidden');
		$(e).parent().css('white-space','nowrap');
		$(e).parent().css('width','calc(100% - 40px)');
		$(e).parent().next().show();
	}
	function openSumDetail(index){//打开报销费用详情
		$.get('/crm/weeklyfinish/totallist?bUser='+listData[index].finishList[0].bUser, function(res){//查询月计、年计
			var sumData = {monthTotal:0,yearTotal:0,vBxsm:''};
			$.each(res.monthTotal[0],function(i,v){//月计合计
				sumData.monthTotal += v;
			})
			$.each(res.yearTotal[0],function(i,v){//年计合计
				sumData.yearTotal += v;
			})
			$.each(listData[index].finishList,function(i,v){
				sumData.fPlaneJe = (sumData.fPlaneJe?sumData.fPlaneJe:0) + v.fPlaneJe;
				sumData.fPlaneNum = (sumData.fPlaneNum?sumData.fPlaneNum:0) + v.fPlaneNum;
				sumData.fTrainJe = (sumData.fTrainJe?sumData.fTrainJe:0) + v.fTrainJe;
				sumData.fTrainNum = (sumData.fTrainNum?sumData.fTrainNum:0) + v.fTrainNum;
				sumData.fBusJe = (sumData.fBusJe?sumData.fBusJe:0) + v.fBusJe;
				sumData.fBusNum = (sumData.fBusNum?sumData.fBusNum:0) + v.fBusNum;
				sumData.fTaxiJe = (sumData.fTaxiJe?sumData.fTaxiJe:0) + v.fTaxiJe;
				sumData.fTaxiNum = (sumData.fTaxiNum?sumData.fTaxiNum:0) + v.fTaxiNum;
				sumData.fPassJe = (sumData.fPassJe?sumData.fPassJe:0) + v.fPassJe;
				sumData.fPassNum = (sumData.fPassNum?sumData.fPassNum:0) + v.fPassNum;
				sumData.fStopJe = (sumData.fStopJe?sumData.fStopJe:0) + v.fStopJe;
				sumData.fStopNum = (sumData.fStopNum?sumData.fStopNum:0) + v.fStopNum;
				sumData.fTrafficJe = (sumData.fTrafficJe?sumData.fTrafficJe:0) + v.fTrafficJe;
				sumData.fTrafficNum = (sumData.fTrafficNum?sumData.fTrafficNum:0) + v.fTrafficNum;
				sumData.fStayJe = (sumData.fStayJe?sumData.fStayJe:0) + v.fStayJe;
				sumData.fStayNum = (sumData.fStayNum?sumData.fStayNum:0) + v.fStayNum;
				sumData.fServeJe = (sumData.fServeJe?sumData.fServeJe:0) + v.fServeJe;
				sumData.fServeNum = (sumData.fServeNum?sumData.fServeNum:0) + v.fServeNum;
				sumData.fTravelJe = (sumData.fTravelJe?sumData.fTravelJe:0) + v.fTravelJe;
				sumData.fTravelNum = (sumData.fTravelNum?sumData.fTravelNum:0) + v.fTravelNum;
				sumData.fOtherJe = (sumData.fOtherJe?sumData.fOtherJe:0) + v.fOtherJe;
				sumData.fOtherNum = (sumData.fOtherNum?sumData.fOtherNum:0) + v.fOtherNum;
				sumData.fTKM = (sumData.fTKM?sumData.fTKM:0) + v.fTKM;
				sumData.fTotalJe = (sumData.fTotalJe?sumData.fTotalJe:0) + v.fTotalJe;
				sumData.vBxsm += (v.vBxsm?(sumData.vBxsm?'\n':'')+v.vBxsm:'');
			})
			var layerHtml = '<table class="layui-table" lay-size="sm" style="margin: 0">';
//	 	layerHtml += '<colgroup>';
//	 	layerHtml += '<col width="50">';
//	 	layerHtml += '<col width="90">';
//	 	layerHtml += '<col width="90">';
//	 	layerHtml += '<col width="90">';
//	 	layerHtml += '<col width="90">';
//	 	layerHtml += '<col width="90">';
//	 	layerHtml += '</colgroup>';
			layerHtml += '<thead>';
			layerHtml += '<tr>';
			layerHtml += '<th>序号</th>';
			layerHtml += '<th>费用名称</th>';
			layerHtml += '<th>金额</th>';
			layerHtml += '<th>票据数量</th>';
			layerHtml += '<th>月计（已生效）</th>';
			layerHtml += '<th>年计（已生效）</th>';
			layerHtml += '</thead>';
			layerHtml += '</tr>';
			layerHtml += '<tbody>';
			layerHtml += '<tr>';
			layerHtml += '<td>1</td>';
			layerHtml += '<td>飞机费</td>';
			layerHtml += '<td>'+(sumData.fPlaneJe?sumData.fPlaneJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fPlaneNum?sumData.fPlaneNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].PlaneJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].PlaneJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>2</td>';
			layerHtml += '<td>火车费</td>';
			layerHtml += '<td>'+(sumData.fTrainJe?sumData.fTrainJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fTrainNum?sumData.fTrainNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].TrainJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].TrainJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>3</td>';
			layerHtml += '<td>大巴费</td>';
			layerHtml += '<td>'+(sumData.fBusJe?sumData.fBusJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fBusNum?sumData.fBusNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].BusJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].BusJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>4</td>';
			layerHtml += '<td>出租车费</td>';
			layerHtml += '<td>'+(sumData.fTaxiJe?sumData.fTaxiJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fTaxiNum?sumData.fTaxiNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].TaxiJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].TaxiJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>5</td>';
			layerHtml += '<td>过路费</td>';
			layerHtml += '<td>'+(sumData.fPassJe?sumData.fPassJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fPassNum?sumData.fPassNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].PassJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].PassJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>6</td>';
			layerHtml += '<td>停车费</td>';
			layerHtml += '<td>'+(sumData.fStopJe?sumData.fStopJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fStopNum?sumData.fStopNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].StopJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].StopJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>7</td>';
			layerHtml += '<td>其他交通费</td>';
			layerHtml += '<td>'+(sumData.fTrafficJe?sumData.fTrafficJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fTrafficNum?sumData.fTrafficNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].TrafficJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].TrafficJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>8</td>';
			layerHtml += '<td>住宿费</td>';
			layerHtml += '<td>'+(sumData.fStayJe?sumData.fStayJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fStayNum?sumData.fStayNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].StayJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].StayJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>9</td>';
			layerHtml += '<td>招待费</td>';
			layerHtml += '<td>'+(sumData.fServeJe?sumData.fServeJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fServeNum?sumData.fServeNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].ServeJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].ServeJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>10</td>';
			layerHtml += '<td>差旅补助</td>';
			layerHtml += '<td>'+(sumData.fTravelJe?sumData.fTravelJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fTravelNum?sumData.fTravelNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].TravelJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].TravelJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>11</td>';
			layerHtml += '<td>其他费用</td>';
			layerHtml += '<td>'+(sumData.fOtherJe?sumData.fOtherJe.toFixed(2):'')+'</td>';
			layerHtml += '<td>'+(sumData.fOtherNum?sumData.fOtherNum.toFixed(0):'')+'</td>';
			layerHtml += '<td>'+res.monthTotal[0].OtherJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].OtherJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td>12</td>';
			layerHtml += '<td>车补费</td>';
			layerHtml += '<td></td>';
			layerHtml += '<td>'+(sumData.fTKM?sumData.fTKM.toFixed(2):0)+'（KM）</td>';
			layerHtml += '<td>'+res.monthTotal[0].BtJeTotalM.toFixed(2)+'</td>';
			layerHtml += '<td>'+res.yearTotal[0].BtJeTotalY.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '<tr>';
			layerHtml += '<td></td>';
			layerHtml += '<td>合计</td>';
			layerHtml += '<td>'+(sumData.fTotalJe?sumData.fTotalJe.toFixed(2):'')+'</td>';
			layerHtml += '<td></td>';
			layerHtml += '<td>'+sumData.monthTotal.toFixed(2)+'</td>';
			layerHtml += '<td>'+sumData.yearTotal.toFixed(2)+'</td>';
			layerHtml += '</tr>';
			layerHtml += '</tbody>';
			layerHtml += '</table>';
			layerHtml += '<textarea class="layui-textarea" style="background: #fbbdcb;min-height: 65px;max-height: 65px" readonly>报销说明：'+sumData.vBxsm+'</textarea>';
			layer.open({
				type: 1,
				fix: false,//不固定
				offset: '10%',//距离顶部
				maxmin: true,//最大最小化
				shade: 0.3,//遮罩
				shadeClose: true,// 弹层外区域关闭
				title: '本次报销费用明细，合计：<b class="price" style="font-size:20px">'+(sumData.fTotalJe?sumData.fTotalJe.toFixed(2):0)+'</b>',
				area: ['600px', '600px'],
				content: layerHtml,
				btn: ['关闭'],
//	 		success: function(layero,index){
//	 			layero.find('.layui-layer-content').css('overflow','unset');
//	 		}
			});
		})
	}
	function transferReturn(type,i){//单个流转或退回
		switch(type){
			case 1:
				var url='/crm/weeklyplan/flowpage?fType=flow_back',
						pd=JSON.stringify(listData[i].planList[0], null, 2),
						title='退回页面';
				break;
			case 2:
				var url='/crm/weeklyfinish/flowpage?fType=flow_back',
						pd=JSON.stringify(listData[i].finishList[0], null, 2),
						title='退回页面';
				break;
			case 3:
				var url='/crm/weeklyplan/flowpage?fType=flow_go',
						pd=JSON.stringify(listData[i].planList[0], null, 2),
						title='流转页面';
				break;
			case 4:
				var url='/crm/weeklyfinish/flowpage?fType=flow_go',
						pd=JSON.stringify(listData[i].finishList[0], null, 2),
						title='流转页面';
				break;
		}
		$.post(url,{'infoMap':pd}, function(res){
			if(res.code==0){
				var mwidth=($(window).width()-100>800)?800:($(window).width()-100),
						mheight=($(window).height()-100>700)?700:($(window).height()-100);
				$.modal.open(title, res.data,mwidth,mheight, function(index){
					var result = window["layui-layer-iframe" + index].processTaskCallback();
					if(result){
						$('.layui-layer-btn0').attr('style','display:none');//隐藏确定按钮
						result.data['infoMap']=pd;//为流转添加infoMap参数
						$.operate.save(result.url, result.data,function(res2){
							if(res2.code==0){
								$.modal.closeLoading();
								layer.closeAll();
								layer.msg(res2.msg,{icon:1});
								$('#btn-search0').click();
								//删除dom及数据并重新加载当页最后一个
//     	                	listData.splice(i,1);
//     	                	$('#weekFlow').find('li')[i].remove();
//     	                	if($('.form3').css('display')=='block')flowPlan('/flowable/weekly/weeklyplan'+urlParameters,((weekPage-1) * weekLimit),1);
//     	                	else flowFinish('/flowable/weekly/weeklyfinish'+urlParameters,((weekPage-1) * weekLimit),1);
							}else{
								layer.closeAll();
								$.modal.msgError(((res2 == undefined)?"操作错误！":res2.msg), modal_status.FAIL);
							}
						});
					}
				});
			}else{
				$.operate.ajaxSuccess(res);
			}
		})
	}
	var successNum = 0;//成功请求个数
	function allRorT(type){//全部通过或退回
		if(listData.length==0){
			layer.msg('无数据，无需操作！',{icon:7,offset: '20%'});
		}else{
			layer.confirm('请选择'+(type==1?'退回':'通过')+'范围：', {
				skin:'reset-class',
				icon: 3,
				offset: '10%',
				title: "系统提示",
				btn: ['已阅', '全部', '取消'],
				yes: function(index, layero){
					layer.closeAll();
// 	        	return true;
					showloadings(true);
					var taskIds = [];
					$.each(listData,function(i,v){taskIds.push(v.taskId);})
					$('#weekProgress').removeClass('layui-hide');
					$.ajaxSettings.async = false;//同步请求
					successNum = 0;
					recursionPost(type,taskIds,0,taskIds.length);
				},
				btn2: function(index, layero){
					$.modal.confirmCom((type==1?'是否全部退回？':'是否全部通过？')+'包括未审阅部分？', function(index){
						layer.closeAll();
//	 	        	return true;
						showloadings(true);
						$.get($('.form3').css('display')=='block'?'/crm/weeklyplan/taskIdList':'/crm/weeklyfinish/taskIdList'+urlParameters,function(res){//获取taskId列表
							if(res.code == 0){
								$('#weekProgress').removeClass('layui-hide');
								$.ajaxSettings.async = false;//同步请求
								successNum = 0;
								recursionPost(type,res.data,0,res.count);
							}else{
								showloadings(false);
								layer.msg(res.msg);
							}
						})
					});
				},
				cancel: function(index, layero){
				}
			});
		}
	}
	function recursionPost(type,data,index,len){//递归post
		var postNum = 8;//每次传输数量
		element.progress('weekProgress', ((index * postNum) / len * 100).toFixed(0)+'%');
		setTimeout(function(){
			$.post(type==1?'/flowable/task/taskBackAllPost':'/flowable/task/taskPassAllPost', {'taskIds':data.slice(0,postNum).join(','),'priority':1,comment:'',medium:''},function(res2){
				++index;
				if(res2.code==0)successNum += data.slice(0,postNum).length;
				if(data <= postNum){//全部请求结束
					element.progress('weekProgress', '100%');
					showloadings(false);
					$.ajaxSettings.async = true;//异步请求
					layer.alert('成功'+(type==1?'退回':'通过')+'：'+successNum+'个，失败：'+(len-successNum)+'个！', {
						icon: $.modal.icon(type),
						offset: '10%',
						title: "系统提示",
						icon: len == successNum?1:7,
						end: function(){
							$('#weekProgress').addClass('layui-hide');
							$('#btn-search0').click();
						}
					});
				}else recursionPost(type,data.slice(postNum,data.length),index,len);
			});
		}, 100);
	}
	function spiltTime(value, date, endDate,startId,endId){//时间控件的回调函数(切割时间字符串)
		var hours = endDate.hours;
		var minutes = endDate.minutes;
		var seconds = endDate.seconds;
		if (hours == "0" && minutes == "0" && seconds == "0"){
			$(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click();
			// 改变结束时间默认值
			$(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click();
		}
		var splitArray = value.split('~');
		var startTime = (splitArray.length > 0) ? splitArray[0] :"";
		var endTime  =  (splitArray.length > 1) ?  splitArray[1] :"";
		$('#'+startId).val(startTime);
		$('#'+endId).val(endTime);
	}
	function newTab(url,title){//打开新页面
		if(top.layui.index)top.layui.index.openTabsPage(url,title);
		else window.open(url);
	}
	function read(url,title,cid,cname,tindex){//查看
		var dcache=table.cache.dhtable2[tindex],
				btn,
				useCss=false;
		if($('[lay-filter=dhtab3] .layui-this').index()==0){//选中未处理选项卡
			switch(dcache['moduleTable']){
				case 'THR_TrainingPlanEntryForm'://在线培训
					btn=['报名','忽略','关闭'];
					useCss=true;
					break;
				case 'THR_TrainingAppraiseLecturer'://培训师评价
				case 'THR_TrainingPlanX'://新员工培训
				case 'THR_TrainingPlanS'://实习生培训
					btn=['保存','提交','关闭'];
					useCss=true;
					break;
				case 'TEDI_SpecialOrder_JS'://特价申请——通知技术（不重复）
				case 'TEDI_SpecialOrder_JS_Repeat'://特价申请——通知技术（重复）
					btn=['回复','关闭'];
					break;
				default:
					btn=['已处理','关闭'];
					break;
			}
		}else btn=['关闭'];
		if($.inArray(dcache['moduleTable'],['TEDI_SpecialOrder_JS','TEDI_SpecialOrder_JS_Repeat','Commonality_Not_Repeat','Commonality_Untreated_Repeat'])>-1)url+='&flowtype=moduletask&isShow=1';//打开可编辑页面（去除表头按钮及页脚）
		openL(title+'-'+cname+'('+cid+')',url,btn,useCss,dcache);
	}
	function openL(title,url,btn,useCss=false,dcache){
		layer.config({extend: 'myskin/style.css'});//加载扩展样式
		layer.open({
			type: 2,
			skin:useCss?'reset-class':'',
			area: [($(window).width() - 400)+'px', ($(window).height() - 200)+'px'],
			fix: false,//不固定
			offset: '10%',//距离顶部
			maxmin: true,//最大最小化
			shade: 0.3,//遮罩
			title: title,
			content: url,
			btn: btn,
			shadeClose: true,// 弹层外区域关闭
			success: function(layero, index){
			},
			btn1: function(index, layero){
				if(btn.toString()==['关闭'].toString()){
					layer.close(index);
				}else{
					if(window["layui-layer-iframe" + index].btn1(dcache)){
						setTimeout(function(){
							layer.close(index);
							table.reload('dhtable2');
							refreshTask();//刷新通知数量
						},1500)
					}
					return false;//开启该代码可禁止点击该按钮关闭（true为开启关闭）
				}
			},
			btn2:function(index,layero){
				if(typeof window["layui-layer-iframe" + index].btn2 !='undefined' && window["layui-layer-iframe" + index].btn2(dcache['guid'])){
					setTimeout(function(){
						layer.close(index);
						table.reload('dhtable2');
						refreshTask();//刷新通知数量
					},1500)
				}else return true;
				return false;//开启该代码可禁止点击该按钮关闭（true为开启关闭）
			}
		});
	}
	function refreshTask(){//刷新通知数量
		$.get('/system/moduletask/listwcls',function(res){
			$('.badge1').text(res.data[0].actCount);//待办流程任务数
			$('.badge2').text(res.data[0].taskCount);//未处理功能任务数
			$('.badge3').text(res.data[0].planCount+res.data[0].finishCount);//计划总结
			if(Number(res.data[0].taskCount)+Number(res.data[0].actCount)>0){//修改导航栏的通知数量
				parent.$('#todoTask').show();
				parent.$('#todoTask').text(Number(res.data[0].taskCount)+Number(res.data[0].actCount));
			}else parent.$('#todoTask').hide();

		});
	}
	var pageWidth = 0;//记录容器宽度
	function waterFall(items) {
		pageWidth = $('.flow-default')[0].offsetWidth;//容器宽度
//     var itemWidth = items[0].offsetWidth;
//     var columns = parseInt((pageWidth - gap) / (itemWidth + gap));//确定列数
		var itemWidth = itemWidth = parseInt((pageWidth - gap*columns - gap - 10) / columns);//重新改变宽度、预留滚动条10像素
		var arr = [];//存储元素的高度
		for (var i = 0; i < items.length; i++) {
			items[i].style.width = itemWidth + 'px';
			if (i < columns) {//确定第一行的位置
				items[i].style.top = gap + 'px';
				items[i].style.left = (itemWidth + gap) * i +gap + 'px';
				arr.push(items[i].offsetHeight + gap);
			} else {//其他行，先找出最小高度列，和索引
				var minHeight = arr[0]; //假设最小高度是第一个元素
				var index = 0;
				for (var j = 0; j < arr.length; j++) {//找出最小高度
					if (minHeight > arr[j]) {
						minHeight = arr[j];
						index = j;
					}
				}
				items[i].style.top = arr[index] + gap + 'px';//top值就是最小列的高度+gap
				items[i].style.left = items[index].offsetLeft + 'px';
				arr[index] = arr[index] + items[i].offsetHeight + gap;//修改最小列的高度 = 当前自己的高度 + 拼接过来的高度 + 间隙的高度
			}
		}
		var index = 0,maxHeight = 0;
		for (var j = 0; j < arr.length; j++) {//找出最大高度
			if (maxHeight < arr[j]) {
				maxHeight = arr[j];
				index = j;
			}
		}
		$('.layui-flow-more')[0].style.position = 'absolute';
		$('.layui-flow-more')[0].style.top = arr[index] + gap + 'px';
//     $('.layui-flow-more')[0].style.left = pageWidth/2 + 'px';
	}
	window.onresize = function () {//当页面尺寸发生变化时，触发函数，实现响应式
		if($('.layui-flow-more').length)waterFall($('#weekFlow').find('li'));
	}
	$('#weekFlow').mouseover(function(){//监听容器，动态改变列
		if(pageWidth != $('.flow-default')[0].clientWidth && $('#weekFlow').find('li').length){
			pageWidth = $('.flow-default')[0].clientWidth;
			waterFall($('#weekFlow').find('li'));
		}
	})
</script>
</body>
</html>